home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / STRFTIM.ZIP / SFTEST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-29  |  681 b   |  36 lines

  1. /* sftest.c */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6.  
  7. #include "strftime.h"
  8.  
  9. main(int argc, char *argv[])
  10. {
  11.     char fs[10], s[80];
  12.     struct tm *stime;
  13.     time_t tt;
  14.  
  15.     time(&tt);
  16.     stime = localtime(&tt);
  17.     
  18.     if (argc < 2)
  19.     {
  20.         printf("usage: %s c\n where c is a strftime format code\n", argv[0]);
  21.         return 10;
  22.     }
  23.     fs[0] = '%';
  24.     fs[2] = '\0';
  25.     while(--argc)
  26.     {
  27.         fs[1] = **++argv;
  28.         if (strftime(s, 80, fs, stime) == 0)
  29.         {
  30.             printf("string overflow  ");
  31.         }
  32.         printf("for format \"%s\" strftime gives \"%s\"\n", fs, s);
  33.     }
  34.     return 0;
  35. }
  36.